from xmlrpc.client import ServerProxy
s = ServerProxy('http://localhost:20001', allow_none=True)
s.set('foo', 'bar')
s.set('spam', [1, 2, 3])
print(f"{s.keys() = }")
print(f"{s.get('foo') = }")
print(f"{s.get('spam') = }")
s.delete('spam')
print(f"{s.exists('spam') = }")

''' 传递一个对象实例'''

class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y

p = Point(2, 3)
s.set('object', p)
print(f"{s.get('object') = }")

'''二进制数据'''
s.set('bin', b'Hello World')
print(f"{s.get('bin') = }")
print(f"{s.get('bin').data = }")
